const dbm = require('../config/dbModels');
const db = require('../config/dbIns');
const { aseDecode}=require('../core/crypto')
const { createJWT,decodeJWTId } = require('../core/jwt')
const { createCookie } = require('../core/do-cookie');

class publicSquareListDao {
  /**
   *  创建笔记
   * @param ctx 浏览器发送的数据
   */
  static async getPublicSquareList(ctx) {
    let { lastId=0,count=10} = ctx.query
    var [err, dbRes] = await db.query(`select * from posts where id>${lastId} limit 0,${count}`)
    if (dbRes.length > 0) { 
      for (var i = 0; i < dbRes.length; i++) { 
        var [errTag, dbResTags] = await db.query(`select tagId, tagCnName from rel_tagList_post where postId=${dbRes[i].id}`)
        console.log('======dbResTags',dbResTags);
        dbRes[i].tag=dbResTags
      }
    }
    console.log('=====是否错误',err);
    return [err,dbRes]
  }
}
module.exports = publicSquareListDao
